package com.fanco.learn_datastruct_leetcode.designpattern.mememto;

/**
 * @author qiaowang 2022/2/23
 * 描述
 */
public class Client {
    public static void main(String[] args) {
        Originator originator = new Originator();

        Caretaker caretaker = new Caretaker();

        originator.setState("状态是#111");

        caretaker.add(originator.saveMemento());

        originator.setState("状态是#222");

        caretaker.add(originator.saveMemento());

        originator.setState("状态是 #333");
        caretaker.add(originator.saveMemento());


        System.out.println("当前状态是" + originator.getState());
        // 希望恢复到 状态1
        originator.getStateFromMemento(caretaker.get(0));

        System.out.println("恢复后状态是" + originator.getState());



    }
}
